package com.system.controller;


import com.system.entity.Shop;
import com.system.service.impl.ShopServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ShopController {

    @Resource
    private ShopServiceImpl shopService;

    @ApiOperation(value="获取所有商铺")
    @GetMapping("/selectAllShop")
    public List<Shop> selectAllShop(){
        List<Shop> shops = shopService.selectAllShop();
        return shops;
    }


    @ApiOperation(value="根据id获取商铺")
    @GetMapping("/selectShopById")
    public Shop selectShopById(int id){
        Shop shop = shopService.selectShopById(id);
        return shop;
    }


    @ApiOperation(value="添加商铺")
    @PostMapping("/insertShop")
    public String insertShop(@RequestBody Shop shop){
        boolean b = shopService.insertShop(shop);
        return b?"success":"fail";
    }

    @ApiOperation(value="修改商铺")
    @PutMapping("/updateShop")
    public String updateShop(@RequestBody Shop shop){
        boolean b = shopService.updateShop(shop);
        return b?"success":"fail";
    }

    @ApiOperation(value="删除商铺")
    @DeleteMapping("/deleteShop")
    public String deleteShop(int id){
        boolean b = shopService.deleteShopById(id);
        return b?"success":"fail";
    }


}
